/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-10-14 09:00:55
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-16 13:31:03
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\EnterpriseFiles.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { TwoAddBtn, ThrDeleteBtn, OpenThrBtn } from '../options'

// enterpriseFileCategory

export const SecurityDetails = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '安全整改记录',
        hideInSearch: true,
        pageSize: 10,
        params: { SecurityUuid: data.uuid },
        classification: 'TableModal',
        get: API_LIST()['getSecurityDetail'],
        options: [
            data.auditStatus === 1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加整改信息"
                    ThrKey="ThrModal"
                    value="SecurityDetails"
                    data={data}
                />
            ),
        ],
        columns: [
            // 名称 描述 日期
            { ...commonTableList.tableName, title: '整改主题' },
            {
                dataIndex: 'description',
                title: '整改描述',
                valueType: 'input',
                rules: true,

                width: 250,
            },
            {
                dataIndex: 'securityDetailDate',
                title: '整改日期',
                valueType: 'Date',
                rules: true,
                width: 250,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, handling } = record
                    return [
                        <OpenThrBtn
                            key="openThr"
                            upDataEvent={upDataEvent}
                            Permission={Permission}
                            title="附件详情"
                            ThrKey="ThrModal"
                            value="SecurityDetailAttachment"
                            data={record}
                        />,
                        handling === 1 &&
                            Permission.findIndex(v => v.uuid === '96967a57-a193-475e-b0ce-5d3425b0ab7e') !== -1 && (
                                <ThrDeleteBtn
                                    key="submit"
                                    title="提交待审"
                                    additional={[uuid]}
                                    record={record.uuid}
                                    upDataEvent={upDataEvent}
                                    data={{
                                        key: 'submit',
                                        url: 'putSecurityDetailSubmit',
                                        title: '提交待审',
                                        content: '提交后将不可继续修改',
                                    }}
                                />
                            ),
                        data.auditStatus === 1 &&
                            handling === 1 &&
                            Permission.findIndex(v => v.uuid === '270bb48e-4e64-4276-b898-00ea14eaaa59') !== -1 && (
                                <ThrDeleteBtn
                                    key="delete"
                                    additional={[uuid]}
                                    record={record.uuid}
                                    upDataEvent={upDataEvent}
                                    data={{ key: 'delete', url: 'delSecurityDetail', title: '删除整改信息' }}
                                />
                            ),
                    ]
                },
            },
        ],
    }
    return dataList
}
